package com.yang;

import com.yang.core.HttpSample;
import com.yang.core.TestResultsSet;
import com.yang.utils.Print;
import com.yang.utils.ReadJTLFile;
import java.util.ArrayList;


public class ParseJTL {

    public static TestResultsSet parseJTL(String fileType, String fileName) {
        TestResultsSet resultsSet = null;
        try {
            ReadJTLFile readJTLFile = new ReadJTLFile();
            ArrayList<HttpSample> httpSamples = null;
            if (fileType.equals("xml")) {
                httpSamples = readJTLFile.parseJtlFileFromXML(fileName);
            } else if (fileType.equals("csv")) {
                httpSamples = readJTLFile.parseJtlFileFromCSV(fileName);
            }
            resultsSet = readJTLFile.getResultsSet(httpSamples);
        } catch (Exception e) {
            System.out.println("Please input file-type paramers \"xml\" or \"csv\"");
            e.printStackTrace();
        }
        return resultsSet;
    }


    public static void main(String[] args) {
        String fileName = "C:\\Users\\Administrator\\Desktop\\111.xml";

        TestResultsSet xml = ParseJTL.parseJTL("xml", fileName);
//        TestResultsSet xml = ParseJTL.parseJTL(args[0], args[1]);
        Print.print(xml);
    }
}
